sketch_rect_model: guard against off-plane model_origin (PR #56 follow-up)#58
sketch_rect_model: guard against off-plane model_origin (PR #56 follow-up)#58YLZha wants to merge 2 commits into
Conversation
modelToSketchSpace flattens the origin onto the sketch plane and the out-of-plane component (sk_o.z) was silently dropped — so an off-plane model_origin created the body IN the plane, not at model_origin. This was the root cause of 3 of the 4 defects in PR #56 (back-panel-at-front). Now raises an immediate, self-explaining ValueError when the origin lies >1e-4 cm off the plane, converting a silent wrong-position defect (caught late by check_interference) into an authoring-time error. A correct call (plane at the right offset) has sk_o.z ~ 0 and is unaffected. Validated: cabinet (heavy multi-plane user, incl. the just-fixed back panel) builds clean — guard does not trip. Broader example sweep pending. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The guard from this branch caught it: KickFront_Sk/KickLeft_Sk sketched on the bare xZ/yZ planes (y=0 / x=0) but their model_origin set the recess (y/x = kick_inset). modelToSketchSpace flattened that onto the case face → the kick was built FLUSH with the front/side instead of recessed for toe clearance (reanchor only fixes the in-plane x/z dims). Fix: sketch on off_planes at kick_inset (same pattern as PR #56's back panels) so the body is correctly recessed and the origin lands on-plane. Static sweep of all examples confirms sideboard is the ONLY example with origin-mode off-plane bugs; the other flagged calls (wardrobe kick, toy-box back, sideboard top) use anchored mode, which handles off-plane origins correctly (wardrobe verified clean in Fusion). NOT yet Fusion-validated — connection dropped mid-sweep. Needs: guard clean + deps/connectivity pass + recessed kick still joins the case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Validation complete — guard is safe, found + fixed 1 real bugGuard live-validated on 6 diverse examples (build clean, no trip)cabinet, wardrobe, bench, crib, sideboard (after fix), bookshelf — covering bare-construction-plane and offset-plane usage, origin-mode and anchored-mode calls. Static sweep of ALL examples for the bug patternA parser over every The bug the guard caught → fixed in this PRsideboard's kick was built flush instead of recessed. Live-validated: sideboard now builds clean, guard doesn't trip, 0 real interference, and the recessed kick frame is properly connected (all 4 kick boards → Bottom + to each other). Doors/drawer remain separate clusters by design (hinged/sliding). Ready to mergeThe one example the guard tripped is fixed and validated; the static sweep + 6 live builds confirm no other regression. CI will cover the rest. |
Summary
Implements the helper guard both reviewers of #56 recommended.
sketch_rect_modelcallsmodelToSketchSpaceto projectmodel_originonto the sketch plane, then silently dropped the out-of-plane component (sk_o.z) — so an off-plane origin created the body IN the plane, not atmodel_origin. This was the root cause of 3 of the 4 defects in #56 (back-panel-at-front).The guard converts that silent wrong-position defect into an immediate, self-explaining error:
A correct call (plane at the right offset) has
sk_o.z ≈ 0and is unaffected — only a wrong plane trips it.Validation
Risk note
This is a
raisein a core helper used by ~every example. If a currently-green example trips, that's a latent position bug to fix (not a guard false-positive — correct calls can't trip). Do not merge until the example sweep is green (CI or manual).🤖 Generated with Claude Code